From c1a482bad3501e6712843c5bf239a2e9db1368b6 Mon Sep 17 00:00:00 2001 From: Ewan Mellor Date: Mon, 25 Dec 2006 16:24:15 +0000 Subject: [PATCH] Cope with corrupt or empty VDI config files. Have to_record return strings rather than integers, as required by the Xen-API spec. Signed-off-by: Ewan Mellor --- tools/python/xen/xend/XendStorageRepository.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tools/python/xen/xend/XendStorageRepository.py b/tools/python/xen/xend/XendStorageRepository.py index adaa96f005..42568e84a7 100644 --- a/tools/python/xen/xend/XendStorageRepository.py +++ b/tools/python/xen/xend/XendStorageRepository.py @@ -103,16 +103,16 @@ class XendStorageRepository: retval = {'uuid': self.uuid, 'name_label': self.name_label, 'name_description': self.name_description, - 'virtual_allocation': self.storage_alloc, - 'physical_utilisation': self.storage_used, - 'physical_size': self.storage_max, + 'virtual_allocation': str(self.storage_alloc), + 'physical_utilisation': str(self.storage_used), + 'physical_size': str(self.storage_max), 'type': self.type, 'location': self.location, 'VDIs': self.images.keys()} if self.storage_max == XEND_STORAGE_NO_MAXIMUM: stfs = os.statvfs(self.location) - retval['physical_size'] = stfs.f_blocks * stfs.f_frsize + retval['physical_size'] = str(stfs.f_blocks * stfs.f_frsize) return retval @@ -148,7 +148,11 @@ class XendStorageRepository: virt_size, phys_size) if cfg_path and os.path.exists(cfg_path): - vdi.load_config(cfg_path) + try: + vdi.load_config(cfg_path) + except: + log.error('Corrupt VDI configuration file %s' % + cfg_path) self.images[image_uuid] = vdi -- 2.30.2